﻿using NetWing.Common.Data.SqlServer;
using System;
using System.Data;
using NetWing.Common;
using NetWing.BPM.Admin.weixin;

namespace NetWing.BPM.Admin.JydModleOrder
{
    public partial class JydOrderFrom : System.Web.UI.Page
    {
        protected string PrintTyy;
        protected string zidai;
        protected string yunshu;
        protected string feiyon;
        protected string myopid;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                myopid = CookieHelper.GetCookie("openid");
                if (!string.IsNullOrEmpty(myopid))
                {


                    string sql = ("select * from Sys_Users where openid='" + myopid + "'");

                    string sql1 = ("select * from jydUser where openid='" + myopid + "'");

                    DataTable dp = SqlEasy.ExecuteDataTable(sql);
                    DataTable op = SqlEasy.ExecuteDataTable(sql1);

                    if (dp == null || op == null)
                    {
                        Response.Redirect("http://szh.s3.natapp.cc/weixin/bindyg.aspx");
                    }
                }
                else
                {
                    //当用户访问dingd.aspx 页面时,系统就会自动获得openid并返回当前页面
                    string reurl = Request.Url.ToString();//获取当前url
                    CookieHelper.WriteCookie("returnurl", reurl);//把返回信息写入cookies
                    bool r = wxhelper.checkLogin();//wxhelper.checkLogin() 该函数会自动去获得用户openid 获得openid后需要返回当前入口页面 reurl 就是获得openid后的入口页面
                    string kk = "";
                }


                DataTable PrintTy = SqlEasy.ExecuteDataTable("select * from Sys_Dics where status=1 and CategoryId=85 order by KeyId asc");

                foreach (DataRow dr in PrintTy.Rows)
                {
                    int iCode = (int)SqlEasy.ExecuteScalar("select * from Sys_Dics where CategoryId=85");
                    if (iCode > 0)
                    {
                        PrintTyy += "<option value=\"" + dr["Title"].ToString() + "\">" + dr["Title"].ToString() + "</option>";
                    }
                }

                DataTable jsd = SqlEasy.ExecuteDataTable("select * from Sys_Dics where status=1 and CategoryId=102 order by KeyId asc");

                foreach (DataRow de in jsd.Rows)
                {
                    int qCode = (int)SqlEasy.ExecuteScalar("select * from Sys_Dics where CategoryId=102");
                    if(qCode > 0)
                    {
                        zidai += "<option value=\"" + de["Title"].ToString() + "\">" + de["Title"].ToString() + "</option>";
                    }
                }

                DataTable yuns = SqlEasy.ExecuteDataTable("select * from Sys_Dics where status=1 and CategoryId=86 order by KeyId asc");

                foreach(DataRow dw in yuns.Rows)
                {
                    int ynus = (int)SqlEasy.ExecuteScalar("select * from Sys_Dics where CategoryId=86");
                    if(ynus > 0)
                    {
                        yunshu += "<option value=\"" + dw["Title"].ToString() + "\">" + dw["Title"].ToString() + "</option>";
                    }
                }

                DataTable feiyong = SqlEasy.ExecuteDataTable("select * from Sys_Dics where status=1 and CategoryId=87 order by KeyId asc");
                foreach (DataRow dy in feiyong.Rows)
                {
                    int feiy = (int)SqlEasy.ExecuteScalar("select * from Sys_Dics where CategoryId=87");
                    if(feiy > 0)
                    {
                        feiyon += "<option value=\"" + dy["Title"].ToString() + "\">" + dy["Title"].ToString() + "</option>";
                    }
                }


            }
        }
    }
}